home *** CD-ROM | disk | FTP | other *** search
/ Universität Tübingen - 1997/1998 Winter / Universität Tübingen - Wintersemester 1997-98 - Uni-Informationssystem und Stadt-Informationssystem.iso / ajs / linkbutt.jav < prev    next >
Text File  |  1997-08-14  |  949b  |  48 lines

  1.  
  2. import java.applet.*;
  3. import java.net.*;
  4. import java.awt.*;
  5.  
  6. /**
  7.  * A simple Link button.
  8.  *
  9.  * @author Arthur van Hoff
  10.  */
  11. public class LinkButton extends Applet {
  12.     URL url;
  13.     AudioClip snd;
  14.  
  15.     public void init() {
  16.     String lbl = getParameter("lbl");
  17.     if (lbl == null) {
  18.         lbl = "link";
  19.     }
  20.     try {
  21.         String str = getParameter("href");
  22.         if (str != null) {
  23.         url = new URL(getDocumentBase(), str);
  24.         }
  25.     } catch (MalformedURLException e) {
  26.     }
  27.  
  28.     setFont(new Font("Helvetica", Font.BOLD, 14));
  29.     setLayout(new BorderLayout());
  30.     add("Center", new Button(lbl));
  31.  
  32.     lbl = getParameter("snd");
  33.     if (lbl != null) {
  34.         snd = getAudioClip(getDocumentBase(), lbl);
  35.     }
  36.     }
  37.     public boolean action(Event evt, Object arg) {
  38.     if (snd != null) {
  39.         snd.play();
  40.     }
  41.     if (url != null) {
  42.         System.out.println("GOTO: " + url);
  43.         getAppletContext().showDocument(url);
  44.     }
  45.     return true;
  46.     }    
  47. }
  48.